package main

import (
	"fmt"
	"time"
)

// func moveZeroes(nums []int) {
//     left, right, n := 0, 0, len(nums)
//     for right < n {
//         if nums[right] != 0 {
//             nums[left], nums[right] = nums[right], nums[left]
//             left++
//         }
//         right++
//     }
// }

func moveZeroes(nums []int) {
	j := 0
	for i := 0; i < len(nums); i++ {
		if nums[i] != 0 {
			nums[j] = nums[i]
			j++
		}
	}

	for i := j; i < len(nums); i++ {
		nums[i] = 0
	}

}

func main() {
	start := time.Now()
	nums := []int{0, 0, 0, 0, 1, 1}
	moveZeroes(nums)
	cost := time.Since(start)
	fmt.Println(nums)
	fmt.Println(cost)

}
